package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.JieSuanBean;
import com.lwj.liwanjia.bean.ScSelectBean;
import com.lwj.liwanjia.impl.ToBuyView;
import com.lwj.liwanjia.model.ToBuyModel;

import java.util.Map;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/17.
 */

public class ToBuyPresenter {
    private ToBuyModel toBuyModel;
    private ToBuyView toBuyView;

    public ToBuyPresenter(ToBuyView toBuyView) {
        this.toBuyView = toBuyView;
        toBuyModel = new ToBuyModel();
    }

    public void toBuyData(Map<String, Object> map, ScSelectBean selectBean) {
        if (toBuyView != null) {
            toBuyModel.toBuyData(map, selectBean, new Subscriber<JieSuanBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    toBuyView.showError((Exception) e);
                }

                @Override
                public void onNext(JieSuanBean jieSuanBean) {
                    toBuyView.toBuyData(jieSuanBean);
                }
            });
        }
    }
}
